package com.imooc;

import com.imooc.controller.WelcomeController;
import com.imooc.entity.User;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.config.BeanDefinition;
import org.springframework.beans.factory.support.AbstractBeanDefinition;
import org.springframework.beans.factory.support.RootBeanDefinition;
import org.springframework.context.ApplicationContext;
import org.springframework.context.annotation.AnnotationConfigApplicationContext;
import org.springframework.context.annotation.ComponentScan;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.support.FileSystemXmlApplicationContext;

import java.util.Arrays;

/**
 * <h1>注册bean定义</h1>
 *  {@link  BeanDefinition}
 *  	{@link AbstractBeanDefinition}
 *  		{@link RootBeanDefinition}
 *
 *
 * @author : dzj
 * @create: 2021-11-04 19:36
 */
@Slf4j
@Configuration
@ComponentScan("com.imooc")
public class Debug0602 {

	public static void main(String[] args) {
		String xmlPath = "F:\\ideaProjectSource\\spring-framework-5.1.x\\spring-demo\\src\\main\\resources\\spring\\spring-config-6-2.xml";
		ApplicationContext ctx = new FileSystemXmlApplicationContext(xmlPath);
 		//1. 无参构造
		User user1a = (User) ctx.getBean("user1");
		User user1b = (User) ctx.getBean("user1");
		log.info("无参构造: user1a: {},user1b: {}, sameBean:{}",user1a, user1b,user1a==user1b);
		// 静态工厂
		User user2a = (User) ctx.getBean("user2");
		User user2b = (User) ctx.getBean("user2");
		log.info("静态工厂: user2a: {},user2b: {}, sameBean:{}",user2a, user2b,user2a==user2b);
		//  实例工厂
		User user3a = (User) ctx.getBean("user3");
		User user3b = (User) ctx.getBean("user3");
		log.info("实例工厂: user3a: {},user3b: {}, sameBean:{}",user3a, user3b,user3a==user3b);
	}
}
